import { IUserState, IUserInfo, IUpdateUserInfo } from "./types"
import CacheLocal from "@/utils/cacheLocal"
import { MutationTree } from "vuex"

// 用 MutationTree 泛型给对象中函数形参 state 赋予类型
const mutations: MutationTree<IUserState> = {
  saveUserInfo(state, payload: IUserInfo) {
    state.userInfo = payload
    CacheLocal.setItem("LSUserInfo", payload)
  },

  updateUserInfo(state, payload: IUpdateUserInfo) {
    state.updateUserInfo = payload
  }
}

export { mutations }
